// In Eclipse -> Project -> Properties -> Java Build Path -> Libraries
// mysql-connector-java-5.0.4-bin.jar

import java.sql.*;
	
public class TryJDBC {

	   public static void main(String[] args) throws Exception{
	      
		  try {
		      Class.forName("com.mysql.jdbc.Driver").newInstance();
		  }
		      catch(ClassNotFoundException e) {
		      System.out.println("Class not found "+ e);
		  }
		  Connection con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/cousin_db","root","Crystal76");
	      
	      PreparedStatement updateemp = con.prepareStatement ("insert into person values(?,?)");
	      updateemp.setString(1,"y456386");
	      updateemp.setString(2,"Oscar");
	      updateemp.executeUpdate();
	      
	      Statement stmt = con.createStatement();	      
	      String query = "select * from person";
	      ResultSet rs =  stmt.executeQuery(query);
	      System.out.println("Id      Name");
	      while (rs.next()) {
	         String id = rs.getString("id");
	         String name = rs.getString("name");
	         System.out.println(id + "  " + name);
	      }      
	   }
	}
